<template>
	<Container>
		<view class="header">
			<view class="header-content" :style="{ background: 'url(' + assignment.backgroundUrl + ')0 0/100% 100%' }">
				<image
					v-for="(item, index) in assignment.articles"
					:key="index"
					:src="item.imageUrl"
					:class="{ success: chooses[index] === 'success', error: chooses[index] === 'error' }"
					:style="{
						position: 'absolute',
						width: item.width,
						height: item.height,
						top: item.top,
						left: item.left,
						zIndex: item.isFront ? 9 : ''
					}"
					@tap="tap(item, index)"
				></image>
			</view>
			<AudioIcon @iconTap="iconTap" :questionPress="questionPress" />
		</view>
		<Question :question="assignment.questionName" />
	</Container>
</template>

<script>
import { mixins } from '../../../common/mixins/assignmentDefault.js'
import AudioIcon from '../audioIcon.vue'
import Question from '../questionName.vue'
import Container from '../container.vue'
export default {
	mixins: [mixins],
	components: { AudioIcon, Question, Container },
	methods: {
		tap: function(item, index) {
			if (this.isComplete) return
			this.isComplete = true
			if (item.isMatched) {
				this.optionStatus('success', index)
				this.$parent.next({
					isSure: true
				})
			} else {
				this.optionStatus('error', index)
				this.$parent.next()
			}
		}
	}
}
</script>

<style scoped lang="stylus">
.header
	height 45vh
	width 100%
	overflow hidden
	border-radius 70rpx
	border 12rpx solid #FCC77D
	box-sizing border-box
	transform translate3d(0, 0, 0)
	position relative
	margin 5vh 0
	.header-content
		position absolute
		height 100%
		width 1080rpx
		left 50%
		top 50%
		transform translate3d(-50%, -50%, 0)
		z-index 98
</style>
